package com.huawei.appgallery.forum.option.post.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputConnectionWrapper;
import android.widget.EditText;
import o.btg;

public class DeletableEditText extends EditText {
    private btg ˎ = null;

    static class b extends InputConnectionWrapper {
        b(InputConnection inputConnection, boolean z) {
            super(inputConnection, z);
        }

        public boolean sendKeyEvent(KeyEvent keyEvent) {
            return super.sendKeyEvent(keyEvent);
        }

        public boolean deleteSurroundingText(int i, int i2) {
            if (i != 1 || i2 != 0) {
                return super.deleteSurroundingText(i, i2);
            }
            if (sendKeyEvent(new KeyEvent(0, 67)) && sendKeyEvent(new KeyEvent(1, 67))) {
                return true;
            }
            return false;
        }
    }

    public DeletableEditText(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    public DeletableEditText(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public DeletableEditText(Context context) {
        super(context);
    }

    public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
        return new b(super.onCreateInputConnection(editorInfo), true);
    }

    protected void onSelectionChanged(int i, int i2) {
        super.onSelectionChanged(i, i2);
        if (this.ˎ != null) {
            this.ˎ.ˊ(this, i, i2);
        }
    }

    public void setSelectionChangedListener(btg o_btg) {
        this.ˎ = o_btg;
    }

    public boolean onTextContextMenuItem(int i) {
        if (this.ˎ != null) {
            this.ˎ.ॱ(i);
        }
        return super.onTextContextMenuItem(i);
    }
}
